
"""
Created on Tue Feb 19 14:55:43 2013

@author: aponteeduarddo@gmail.com
Copyright Eduardo Aponte 2013.
"""

from mex_binder import binder_py

eyelink_command_result = binder_py('mx_eyelink_command_result')
eyelink_command_result.mx_c.headers = ['<eyelink.h>','"mex.h"']
eyelink_command_result.bindo += []
eyelink_command_result.mx_c.code = \
"""
INT16 _main( void )
{
    return eyelink_command_result( );
}

void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
    mwSize td[2] = {1,1};
    double *status;
    
    
    /* Verify input arguments. */
    if(nrhs != 0 ) {
        mexErrMsgTxt("Incorrect number of inputs.");
    } else if( nlhs > 1 ) {
        mexErrMsgTxt("Too many output arguments.");
    }
      
    plhs[0] = mxCreateNumericArray( 2, td, mxDOUBLE_CLASS, mxREAL);
    status = mxGetPr(plhs[0]);
    *status = (double ) _main( );   
    return;
}
"""

eyelink_command_result.mx_c.mdoc = \
"""function [ ] = mx_eyelink_command_result( )
%MX_EYELINK_COMMAND_RESULT Check for and retrieves the numeric result code sent
% by the tracker from the last command.
%
% Returns:
% NO_REPLY if no reply to last command.
% OK_RESULT (0) if OK.
% Other error codes represent tracker execution error.
%
"""
eyelink_command_result.write_c()
eyelink_command_result.write_m()
eyelink_command_result.compile()
eyelink_command_result.write_sh()

